from flask.views import MethodView
from flask import Flask
app=Flask(__name__)

class UserView(MethodView):
    def get(self, user_id):
        # 处理 GET 请求逻辑
        return "这是get请求的处理："+str(user_id)
    def post(self):
        # 处理 POST 请求逻辑
        return "这是post请求的处理..."
    def put(self, user_id):
        # 处理 PUT 请求逻辑
        return "这是put请求的处理："+str(user_id)
    def delete(self, user_id):
        # 处理 DELETE 请求逻辑
        return "这是delete请求的处理："+str(user_id)

user_view=UserView.as_view('user')
app.add_url_rule('/users/',view_func=user_view,methods=['POST'])
app.add_url_rule('/users/<int:user_id>',view_func=user_view,methods=['GET','PUT', 'DELETE'])

if __name__ == '__main__':
    app.run()


